<?php
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

$params = array_merge(
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params/params.php')
);
$mail = require(__DIR__.'/mail.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
	'defaultRoute' => 'site/index',
    'components' => [
		'i18n' => require(__DIR__.'/i18n.php'),
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'vam_dsp',
        ],
		'session' => [
		    'class' => 'yii\web\DbSession',
		    // Set the following if want to use DB component other than
		    // default 'db'.
		    // 'db' => 'mydb',
		    // To override default session table set the following
			//'sessionName' => 'slsession',
		    'sessionTable' => 'yii_session',
        ],
		'view' => [
            'class' => 'yii\web\View',
            'renderers' => [
                'tpl' => [
                    'class' => 'yii\smarty\ViewRenderer',
                    //'cachePath' => '@runtime/Smarty/cache',
                ],
            ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => false,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'assetManager' => [
            'appendTimestamp' => YII_ENV_PROD ? true : false,
        ],
        'mailer' => $mail,
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db/db.php'),
		'urlManager' => require(__DIR__ . '/router.php'),
        'redis' => require(__DIR__ . '/redis/redis.php'),
    ],

	//'ssp' => require(__DIR__ . '/ssp.php'),
    'params' => $params,
    'aliases' => [
		'@response' => '/response',
		//'@response' => '../web/response',
    ],
    'language' =>'zh-CN',  //增加此行，默认使用中文
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
	$secure = ['allowedIPs' => ['*']];
    
	$config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\debug\Module'] + $secure;

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\gii\Module'] + $secure;

}
$rbac = require(dirname(__FILE__) . '/adminRbac.php');
$config = ArrayHelper::merge($config, $rbac);

return $config;
